def firstMissingPositive(nums):
    table = {}
    for num in nums:
        if num < 0:
            num = 0
        table[num] = True
    i = 1
    while i < len(nums) + 2:
        if i in table:
            i += 1
        else:
            break
    return i


print(firstMissingPositive([1, 2, 0]))  # 3
print(firstMissingPositive([3, 4, -1, 1]))  # 2
print(firstMissingPositive([7, 8, 9, 11, 12]))  # 1
print(firstMissingPositive([2, 1]))  # 3
